﻿using Grow.Module.Service;
using MapsterMapper;

namespace Grow.ObjectMapper.Mapster
{
    public class ObjectMapper : IObjectMapper
    {
        private readonly IMapper _mapper;
        public ObjectMapper(IServiceContext serviceContext)
        {
            _mapper = serviceContext.GetRequiredService<IMapper>();
        }

        public TResult Map<TSource, TResult>(TSource source)
        {
            return _mapper.From(source).AdaptToType<TResult>();
        }

        //public TResult Map<TSource1 ,TSource2, TResult>(TSource1 source1, TSource2 source2)
        //{
        //    return _mapper.From(()).AdaptToType<TResult>();
        //}
        public TResult Map<TSource, TResult>(TSource source, TResult result)
        {
            return _mapper.From(source).AdaptTo(result);
        }

        //public TResult Map<TSource1, TSource2, TResult>(TSource1 source1, TSource2 source2, TResult result)
        //{
        //    return _mapper.From((source1, source2)).AdaptTo(result);
        //}
    }
}
